package com.gouqi.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gouqi.model.dto.statistic.AppAnswerCountDTO;
import com.gouqi.model.dto.statistic.AppAnswerResultCountDTO;
import com.gouqi.model.entity.UserAnswer;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface UserAnswerMapper extends BaseMapper<UserAnswer> {

    @Select("select app_id, count(user_id) as answer_count from user_answer\n" +
            "    group by app_id order by answer_count desc limit 10;")
    List<AppAnswerCountDTO> doAppAnswerCount();


    @Select("select result_name, count(result_name) as result_count from user_answer\n" +
            "    where app_id = #{app_id}\n" +
            "    group by result_name order by result_count desc;")
    List<AppAnswerResultCountDTO> doAppAnswerResultCount(Long app_id);
}




